package com.clarence.dada.modular.system.menu.controller;

import com.clarence.dada.core.base.PageResult;
import com.clarence.dada.core.base.Result;
import com.clarence.dada.modular.system.menu.entity.req.SysMenuButtonReq;
import com.clarence.dada.modular.system.menu.entity.resp.SysMenuButtonResp;
import com.clarence.dada.modular.system.menu.service.SysMenuButtonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 系统菜单按钮控制器
 *
 * @author GD
 * @since 2021/1/9 16:08
 */
@RestController
@RequestMapping("/system/sysMenuButton/")
@Tag(name = "菜单按钮管理", description = "菜单按钮管理Controller")
public class SysMenuButtonController {

    @Resource
    private SysMenuButtonService sysMenuButtonService;

    /**
     * 添加系统菜单按钮
     *
     * @param req 菜单按钮请求参数
     * @author GD
     * @since 2021/1/9 11:28
     */
    @Operation(summary = "系统菜单按钮_新增", description = "新增菜单按钮")
    @PostMapping("menuButtonAdd")
    public Result<Void> menuButtonAdd(@RequestBody @Validated(SysMenuButtonReq.add.class) SysMenuButtonReq req) {
        sysMenuButtonService.menuButtonAdd(req);
        return Result.SUCCESS;
    }

    /**
     * 添加系统菜单按钮-默认按钮
     *
     * @author GD
     * @since 2021/1/9 11:28
     */
    @Operation(summary = "系统菜单按钮_增加默认按钮", description = "添加默认菜单按钮")
    @PostMapping("addDefaultButtons")
    public Result<Void> addDefaultButtons(@RequestBody @Validated(SysMenuButtonReq.defaultButtons.class) SysMenuButtonReq req) {
        sysMenuButtonService.addDefaultButtons(req);
        return Result.SUCCESS;
    }

    /**
     * 批量删除多个系统菜单按钮
     *
     * @param req 菜单按钮id集合
     * @author GD
     * @since 2021/1/9 12:27
     */
    @Operation(summary = "系统菜单按钮_批量删除", description = "批量删除菜单按钮")
    @PostMapping("menuButtonBatchDelete")
    public Result<Void> menuButtonBatchDelete(@RequestBody @Validated(SysMenuButtonReq.batchDelete.class) SysMenuButtonReq req) {
        sysMenuButtonService.menuButtonBatchDelete(req);
        return Result.SUCCESS;
    }

    /**
     * 编辑系统菜单按钮
     *
     * @param req 菜单按钮请求参数
     * @author GD
     * @since 2021/1/9 12:00
     */
    @Operation(summary = "系统菜单按钮_编辑", description = "编辑菜单按钮")
    @PostMapping("menuButtonEdit")
    public Result<Void> menuButtonEdit(@RequestBody @Validated(SysMenuButtonReq.edit.class) SysMenuButtonReq req) {
        sysMenuButtonService.menuButtonEdit(req);
        return Result.SUCCESS;
    }

    /**
     * 获取菜单按钮详情
     *
     * @param req 菜单按钮id
     * @author GD
     * @since 2021/1/9 11:53
     */
    @Operation(summary = "系统菜单按钮_查看", description = "查看菜单按钮")
    @GetMapping("menuButtonDetail")
    public Result<SysMenuButtonResp> menuButtonDetail(@Validated(SysMenuButtonReq.detail.class) SysMenuButtonReq req) {
        return new Result<>(sysMenuButtonService.menuButtonDetail(req));
    }

    /**
     * 获取菜单按钮列表（分页）
     *
     * @param req 菜单id
     * @author GD
     * @since 2021/1/9 12:33
     */
    @Operation(summary = "系统菜单按钮_列表（分页）", description = "菜单按钮列表（分页）")
    @GetMapping("menuButtonPage")
    public Result<PageResult<SysMenuButtonResp>> menuButtonPage(@Validated(SysMenuButtonReq.list.class) SysMenuButtonReq req) {
        return new Result<>(sysMenuButtonService.menuButtonPage(req));
    }

}
